<template>
	<view class="container">
		<scroll-view scroll-y class="content">
			<view class="title" :style="{ marginTop: safeTop + 'px' }">个人中心</view>

			<!-- 登录后 -->
			<view v-if="isLogin">
				<!-- 用户信息区域 -->
				<view class="user-section">
					<view class="user-info">
						<view class="avatar-container" @click="goToSetting">
							<image :src="userInfo.avatar || '/static/images/f.png'" class="user-avatar"
								mode="aspectFill" />
							<!-- <image v-if="userInfo.isVIP" src="/static/base/designer/vip.svg" class="avatar-vip-icon" /> -->
							<image v-if="userInfo.identity != 2 & userInfo.work_level > 0" class="avatar-vip-icon"
								:src="'/static/base/user-center/level/'+levelImg">
							</image>
						</view>
						<view class="user-details">
							<view style="display: flex;align-items: center;">
								<text class="user-name">{{ userInfo.nickname || '未设置昵称' }}</text>
								<!-- <image v-if="userInfo.identity != 2" class="mvp-img" src="/static/images/member01.png">
								</image>-->
								<!-- {{ userInfo.identity == 2 ? '' : levelName }} -->
								<!-- <image v-if="userInfo.identity != 2 & userInfo.work_level > 0" class="mvp-img"
								 :src="'/static/base/user-center/level/'+levelImg">
								</image> -->
								<text style="margin-left:20rpx"
									v-if="userInfo.identity != 2 & userInfo.work_level == 0">普通创作者</text>
								<view class="designer-tag" v-if="userInfo.identity == 2">
									<image class="designer-icon" src="/static/base/index/write.png"></image>
									设计师
								</view>

								<!-- <text v-if="userInfo.identity == 2" class="identity-title">设计师</text> -->
							</view>

							<view>
								<text v-if="userInfo.identity != 2"
									class="phone-number-text">{{ userInfo.phoneNumber }}</text>
							</view>
							<!-- <view>
								<text class="signature-text">{{ userInfo.signature }}</text>
							</view> -->
						</view>


						<!-- 设置按钮 -->
						<view class="setting-icon">
							<image src="/static/base/user-center/seting.png" class="setting-img" mode="aspectFit"
								@click="goToSetting" />
						</view>

						<!-- <view style="margin-left: 20rpx;" @click="goToDesignerApply" class="setting-icon"
							v-if="userInfo.identity == 2">
							<button open-type="share">
								<image src="/static/base/tablebar/designer.png" class="setting-img" mode="aspectFit" />
							</button>
						</view> -->
					</view>
				</view>

				<!-- 我的数据 -->
				<view class="stats-section">
					<view class="stats-content">
						<view class="stat-item">
							<image class="stat-item-img" mode="aspectFit" src="/static/base/user-center/type/1.svg"></image>
							<text class="stat-number">{{ userInfo.comment_count || 0 }}</text>
							<!-- <text class="stat-label">评论</text> -->
						</view>
						<view class="stat-item">
							<image class="stat-item-img" mode="aspectFit" src="/static/base/user-center/type/2.svg"></image>
							<text class="stat-number">{{ userInfo.work_like_count || 0 }}</text>
							<!-- <text class="stat-label">点赞量</text> -->
						</view>
						<view class="stat-item">
							<image class="stat-item-img" mode="aspectFit" src="/static/base/user-center/type/3.svg"></image>
							<text class="stat-number">{{ userInfo.share_count || 0 }}</text>
							<!-- <text class="stat-label">分享</text> -->
						</view>
						<view class="stat-item" @click="goToFansList">
							<image class="stat-item-img" mode="aspectFit" src="/static/base/user-center/type/4.svg"></image>
							<text class="stat-number">{{ userInfo.fans_count || 0 }}</text>
							<!-- <text class="stat-label">粉丝数量</text> -->
						</view>
						<view class="stat-item" @click="goToFollowList">
							<image class="stat-item-img" mode="aspectFit" src="/static/base/user-center/type/5.svg"></image>
							<text class="stat-number">{{ userInfo.follow_count || 0 }}</text>
							<!-- <text class="stat-label">关注数量</text> -->
						</view>
					</view>
				</view>

				<view class="vip-income-box">
					<!-- 会员权益区域（isVIP 逻辑需后续确认） -->
					<view class="membership-section" v-if="userInfo.identity != 2">
						<image class="vip-bg" src="/static/base/user-center/level/vip_bk.png"></image>
						<!-- <image src="/static/base/user-center/level/vip_icon.png" class="vip-icon" mode="aspectFit" /> -->
						<view class="vip-text">
							<text class="membership-title">会员可享多项权益</text>
							<text class="membership-expire">会员到期：{{ userInfo.overdue_time || '未设置' }}</text>
						</view>
						<view class="renew-btn" v-if="userInfo.is_renew == 1" @click="goToRecharge">
							<text class="renew-text">续费</text>
						</view>
						<!-- 本地调试时测试 -->
						<!-- <view class="renew-btn" @click="goToRecharge">
						<text class="renew-text">续费</text>
					</view> -->

					</view>

					<!-- 收益 -->
					<view class="stats-header" @click="toProfitPage">
						<image src="/static/base/user-center/incom-bg.png" class="income-bg"></image>
						<view class="stat-item-first" style="justify-self: left;margin-bottom: 10rpx;">
							<text class="stat-number-first">{{ userInfo.income || '0.00' }}</text>
							<text class="stat-label">累计收益 (元)</text>
						</view>
						<text class="stats-view">
							<text class="iconfont icon-jiantou" style="font-size: 48rpx;"></text>
						</text>
					</view>

				</view>

				<!-- 订单中心 -->
				<view class="order-wrapper" v-if="userInfo.identity != 2">
					<view class="order-hd flex">
						<view class="left">{{ $t('订单中心') }}</view>
						<view class="right flex" @click="goMenuPage('/pages/goods/order_list/index')">
							{{ $t('查看全部') }}
							<text class="iconfont icon-jiantou" style="font-size: 38rpx;"></text>
						</view>
					</view>


					<!-- 订单中心图标，如果采用的是自定义图标，放开上面，后台设置图标放下面注释 -->
					<view class="order-bd">
						<block v-for="(item, index) in orderMenu" :key="index">
							<view class="order-item" @click="goMenuPage(item.url)">
								<view class="pic">
									<image :src="item.img" mode="heightFix"></image>
									<!-- <text class="iconfont" :class="item.img"></text> -->
									<text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
								</view>
								<view class="txt">{{ $t(item.title) }}</view>
							</view>
						</block>
					</view>
				</view>

				<!-- 会员菜单 -->
				<view class="user-menus" style="margin-top: 36rpx" v-if="userInfo.identity != 2">
					<view class="menu-title">{{ $t('商城服务') }}</view>
					<view class="list-box">
						<!-- #ifdef APP-PLUS || H5 -->
						<block v-for="(item, index) in MyMenus" :key="index">
							<view class="item" @click="goMenuPage(item.url, item.name)">
								<image :src="item.pic"></image>
								<text class="name">{{ $t(item.name) }}</text>
								<text class="iconfont icon-jiantou" v-if="my_menus_status == 2"></text>
							</view>
						</block>
						<!-- #endif -->
						<!-- #ifdef MP -->
						<block v-for="(item, index) in MyMenus" :key="index">
							<view class="item" v-if="
									(item.url != '#' && item.url != '/pages/service/index' && item.url != '/pages/extension/customer_list/chat') ||
									(item.url == '/pages/extension/customer_list/chat' && routineContact == 0)
								" @click="goMenuPage(item.url, item.name)">
								<image :src="item.pic"></image>
								<text class="name">{{ $t(item.name) }}</text>
								<text class="iconfont icon-jiantou" v-if="my_menus_status == 2"></text>
							</view>
						</block>

						<button class="item" open-type="contact" v-if="routineContact == 1">
							<image src="/static/images/contact.png"></image>
							<text class="name">{{ $t('联系客服') }}</text>
							<text class="iconfont icon-jiantou" v-if="my_menus_status == 2"></text>
						</button>
						<!-- #endif -->
						<!-- #ifdef APP-PLUS -->
						<view class="item" hover-class="none" @click="goMenuPage('/pages/users/privacy/index?type=3')">
							<image src="/static/images/menu.png"></image>
							<text class="name">{{ $t('隐私协议') }}</text>
							<text class="iconfont icon-jiantou" v-if="my_menus_status == 2"></text>
						</view>
						<!-- #endif -->
					</view>
				</view>
				<view class="user-menus" style="margin-top: 36rpx"
					v-if="userInfo.identity != 2 && business_status && storeMenu.length">
					<view class="menu-title" v-if="business_status == 1">{{ $t('商家管理') }}</view>
					<view :class="{ 'list-box': business_status == 1, 'column-box': business_status == 2 }">
						<block v-for="(item, index) in storeMenu" :key="index">
							<view class="item" :url="item.url" hover-class="none"
								v-if="item.url != '#' && item.url != '/pages/service/index'"
								@click="goMenuPage(item.url, item.name)">
								<image :src="item.pic"></image>
								<text class="name">{{ $t(item.name) }}</text>
								<text class="iconfont icon-jiantou" v-if="business_status == 2"></text>
							</view>
						</block>
					</view>
				</view>

				<!-- 共创中心（始终显示） -->
				<view class="section">
					<view class="section-header">
						<text class="section-title">共创中心</text>
						<text class="iconfont icon-jiantou" style="font-size: 28rpx;"></text>
					</view>
					<scroll-view scroll-x class="horizontal-scroll">
						<view class="creative-list" v-if="creativeWorks.length > 0">
							<view v-for="(item, index) in creativeWorks" :key="index" class="creative-item"
								@click="goToCreativeDetail(item.id)">
								<view class="creative-container">
									<image :src="item.image" class="creative-image" mode="aspectFill" />
								</view>
								<view class="creative-info">
									<text class="creative-title">{{ item.title }}</text>
									<view class="creative-meta">
										<image :src="item.avatar" class="avatar" mode="aspectFill" />
										<text class="creative-author">{{ item.author }}</text>
										<text class="creative-likes">{{ item.likes }}赞</text>
									</view>
								</view>
							</view>
						</view>
						<view v-else class="empty-placeholder">
							<!-- <image src="/static/base/empty.png" class="empty-image" mode="aspectFit" /></image> -->
							<image :src="imgHost + '/statics/images/no-thing.png'" class="empty-image" mode="aspectFit">
							</image>
						</view>
					</scroll-view>
					<view class="view-more-btn" @click="goToCreativeList">
						查看更多 <image class="more-icon" src="/static/base/more.png">
					</view>
				</view>

				<view style="background-color: #F2F8FC;">
					<!-- 我创作的 -->
					<view class="section">
						<view class="section-header">
							<text class="section-title">我创作的</text>
							<!-- <text class="more-btn" @click="goToMyCreations">查看全部</text> -->
							<text class="iconfont icon-jiantou" style="font-size: 28rpx;"></text>
						</view>
						<scroll-view scroll-x class="horizontal-scroll">
							<view class="my-creations-grid-container" v-if="creations.length > 0">
								<view v-for="(item, index) in creations" :key="index" class="creation-item"
									:class="{ 'first-item': index === 0 }" @click="goToCreativeDetail(item.id)">
									<view class="image-container">
										<image :src="item.image" class="product-image" mode="aspectFill" />
									</view>
								</view>
							</view>
							<view v-else class="empty-placeholder">
								<!-- <image src="/static/base/empty.png" class="empty-image" mode="aspectFit" /></image> -->
								<image :src="imgHost + '/statics/images/no-thing.png'" class="empty-image"
									mode="aspectFit"></image>
							</view>
						</scroll-view>
					</view>
				</view>
			</view>

			<!-- 登录前 -->
			<view v-else>
				<!-- 用户信息区域 -->
				<view class="user-section">
					<view class="user-info">
						<view class="avatar-container">
							<image src="/static/images/f.png" class="user-avatar" mode="aspectFill" />
						</view>
						<view class="user-details" @click="openLogin">
							<text class="user-name">点击登录</text>
						</view>
					</view>
				</view>

				<!-- 我的数据 -->
				<view class="stats-section">
					<view class="stats-content">
						<view class="stat-item">
							<text class="stat-number">0</text>
							<text class="stat-label">评论</text>
						</view>
						<view class="stat-item">
							<text class="stat-number">0</text>
							<text class="stat-label">点赞量</text>
						</view>
						<view class="stat-item">
							<text class="stat-number">0</text>
							<text class="stat-label">分享</text>
						</view>
						<view class="stat-item" @click="goToFansList">
							<text class="stat-number">0</text>
							<text class="stat-label">粉丝数量</text>
						</view>
						<view class="stat-item" @click="goToFollowList">
							<text class="stat-number">0</text>
							<text class="stat-label">关注数量</text>
						</view>
					</view>
				</view>

				
				<view class="vip-income-box">
					<!-- 会员权益区域（isVIP 逻辑需后续确认） -->
					<view class="membership-section" v-if="userInfo.identity != 2">
						<image class="vip-bg" src="/static/base/user-center/level/vip_bk.png"></image>
						<!-- <image src="/static/base/user-center/level/vip_icon.png" class="vip-icon" mode="aspectFit" /> -->
						<view class="vip-text">
							<text class="membership-title">会员可享多项权益</text>
							<text class="membership-expire">会员到期：{{ userInfo.overdue_time || '未设置' }}</text>
						</view>
						<!-- 本地调试时测试 -->
						<!-- <view class="renew-btn" @click="goToRecharge">
						<text class="renew-text">续费</text>
					</view> -->
				
					</view>
				
					<!-- 收益 -->
					<view class="stats-header">
						<image src="/static/base/user-center/incom-bg.png" class="income-bg"></image>
						<view class="stat-item-first" style="justify-self: left;margin-bottom: 10rpx;">
							<text class="stat-number-first">{{ userInfo.income || '0.00' }}</text>
							<text class="stat-label">累计收益 (元)</text>
						</view>
						<text class="stats-view">
							<image style="width: 55rpx;height: 55rpx;" src="/static/base/more.png"></image>
						</text>
					</view>
				
				</view>
				
				<view style="height: 30rpx;"></view>
				<view style="background-color: #F2F8FC;">
					<!-- 我创作的等区域（登录前展示空状态） -->
					<!-- ... 保持原样，略 ... -->
					<!-- 为节省篇幅，此处省略重复结构，实际代码保留 -->
					<view class="section">
						<view class="section-header">
							<text class="section-title">我创作的</text>
							<!-- <text class="more-btn" @click="openLogin">查看全部</text> -->
							<image class="second-more-icon" src="/static/base/more.png" @click="openLogin"></image>
						</view>
						<scroll-view scroll-x class="horizontal-scroll">
							<view class="my-creations-grid-container">
								<view class="creation-item first-item">
									<view class="image-container">
										<image src="/static/base/empty.png" class="product-image" mode="aspectFill" />
									</view>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
			</view>

			<view style="height: 189rpx;"></view>
		</scroll-view>

		<TableBar :current="3" :messagecount="messagecount" />
	</view>
</template>

<script>
	import TableBar from '@/components/base/table-bar/Index.vue'
	import {
		getUnreadMessage
	} from '@/api/base/message.js'
	import {
		getMyWorkList
	} from '@/api/base/designer.js'
	import {
		getWorkList
	} from '@/api/base/index.js'
	import {
		getBaseUserInfo
	} from '@/api/base/user-center'; // 注意：新接口无参数
	import {
		getOrderList,
		getCartList
	} from '@/api/order.js'
	import {
		mapGetters
	} from 'vuex'
	import {
		toLogin
	} from '@/libs/login.js'
	import Cache from '@/utils/cache';
	import {
		USER_INFO,
		UID,
		LOGIN_STATUS
	} from '@/config/cache';
	import {
		HTTP_REQUEST_URL
	} from '@/config/app';

	import {
		getCollectUserList
	} from '@/api/store.js';

	import {
		getMenuList,
		getUserInfo,
	} from '@/api/user.js';
	export default {
		components: {
			TableBar
		},
		computed: {
			...mapGetters(['isLogin']),
			levelName() {
				const map = ['普通创作者', '青铜创作者', '白银创作者', '黄金创作者', '钻石创作者', '王者创作者'];
				return map[this.userInfo.work_level];
			},
			levelImg() {
				const map = ['', '1.png', '2.png', '3.png', '4.png', '5.png'];
				return map[this.userInfo.work_level];
			}
		},
		data() {
			return {
				MyMenus: [],
				orderMenu: [{
						// img: 'icon-daifukuan',
						title: '待付款',
						url: '/pages/goods/order_list/index?status=0'
					},
					{
						// img: 'icon-daifahuo',
						title: '待发货',
						url: '/pages/goods/order_list/index?status=1'
					},
					{
						// img: 'icon-daishouhuo',
						title: '待收货',
						url: '/pages/goods/order_list/index?status=2'
					},
					{
						// img: 'icon-daipingjia',
						title: '待评价',
						url: '/pages/goods/order_list/index?status=3'
					},
					{
						// img: 'icon-a-shouhoutuikuan',
						title: '售后/退款',
						url: '/pages/users/user_return_list/index'
					}
				],
				messagecount: 0,
				imgHost: HTTP_REQUEST_URL,
				safeTop: 0,
				currentUId: '0',
				// 初始化 userInfo 字段，与后端返回对齐
				userInfo: {
					uid: 0,
					nickname: '',
					avatar: '',
					signature: '',
					identity: 0,
					income: '0.00', // 累计收益
					identity_name: '',
					work_count: 0,
					follow_count: 0,
					fans_count: 0,
					comment_count: 0,
					work_like_count: 0,
					share_count: 0,
					// 以下字段后端未返回，保留但设默认值
					isVIP: false, // 需后续确认 VIP 判断逻辑
					phoneNumber: '',
					vipDate: ''
				},
				creations: [],
				possessions: [],
				wishes: [],
				creativeWorks: []
			}
		},
		onShareAppMessage() {
			console.error(this.userInfo.uid)
			console.error(this.userInfo.nickname)
			return {
				title: '好友邀请您成为设计师',
				// path: '/pages/base/user-center/index?invite_uid=' + this.userInfo.uid + '&invite_Name=' + this
				// 	.userInfo.nickname
				path: '/pages/sub_base/designer-apply/index?invite_uid=' + this.userInfo.uid + '&invite_Name=' + this
					.userInfo.nickname
			}
		},
		onLoad(option) {
			const {
				barTop
			} = this.$util.getWXStatusHeight();
			this.safeTop = barTop + 20;
			console.error(option)
			console.error('mycenter onLoad ', option)
			if (option.invite_uid) {
				this.invite = {}
				this.invite.invite_uid = option.invite_uid
				this.invite.invite_Name = option.invite_Name
			}
		},
		onShow() {
			if (this.isLogin) {
				this.currentUId = Cache.get(UID);
				this.getUserInfo(); // 调用无参接口
				this.loadUserCreations();
				this.loadCreativeWorks();
				this.loadMyPossessions();
				this.loadMyWishes();
				console.error('mycenter onshow ', this.invite)
				this.initMessage();
				this.getMyMenus();
			}
		},
		methods: {
			toProfitPage() {
				uni.navigateTo({
					url: "/pages/base/between-home/more-data/index"
				})
			},
			// goMenuPage
			goMenuPage(url, name) {
				if (this.isLogin) {
					if (url.indexOf('http') === -1) {
						// #ifdef H5 || APP-PLUS
						if (name && name === '客服接待') {
							// return window.location.href = `${location.origin}${url}`
							return uni.navigateTo({
								url: `/pages/annex/web_view/index?url=${location.origin}${url}`
							});
						} else if (name && name === '联系客服') {
							return getCustomer(url);
						} else if (name === '订单核销') {
							return uni.navigateTo({
								url: url
							});
							// return window.location.href = `${location.origin}${url}`
						}
						// #endif

						// #ifdef MP
						if (name && name === '联系客服') {
							return getCustomer(url);
						}
						if (url != '#' && url == '/pages/users/user_info/index') {
							uni.openSetting({
								success: function(res) {}
							});
						}
						// #endif
						uni.navigateTo({
							url: url,
							fail(err) {
								uni.switchTab({
									url: url
								});
							}
						});
					} else {
						uni.navigateTo({
							url: `/pages/annex/web_view/index?url=${url}`
						});
					}
				} else {
					// #ifdef MP
					this.openAuto();
					// #endif
					// #ifndef MP
					toLogin();
					// #endif
				}
			},

			/**
			 *
			 * 获取个人中心图标
			 */
			switchTab(order) {
				this.orderMenu.forEach((item, index) => {
					switch (item.title) {
						case '待付款':
							item.img = order.dfk;
							break;
						case '待发货':
							item.img = order.dfh;
							break;
						case '待收货':
							item.img = order.dsh;
							break;
						case '待评价':
							item.img = order.dpj;
							break;
						case '售后/退款':
							item.img = order.sh;
							break;
					}
				});
			},
			getMyMenus: function() {
				this.MyMenus = [{
						"id": 1167,
						"name": "积分中心",
						"pic": "https:\/\/test.accmee.com\/\/uploads\/attach\/2025\/10\/20251006\/e0297d21bc589d73a48fe0c7fdf541ba.png",
						"url": "\/pages\/users\/user_integral\/index"
					},
					{
						"id": 1168,
						"name": "浏览记录",
						"pic": "https:\/\/test.accmee.com\/\/uploads\/attach\/2025\/10\/20251006\/66921d64437cd99b5cda6c3e4c18c305.png",
						"url": "\/pages\/users\/visit_list\/index"
					},
					{
						"id": 1169,
						"name": "我想要的",
						"pic": "https:\/\/test.accmee.com\/\/uploads\/attach\/2025\/10\/20251006\/a6b1f3febd6f72191df21cc3070e34ec.png",
						"url": "\/pages\/users\/user_goods_collection\/index"
					},
					{
						"id": 1170,
						"name": "我的地址",
						"pic": "https:\/\/test.accmee.com\/\/uploads\/attach\/2025\/10\/20251006\/55adf5a41aa1565a68109acbf1f156ee.png",
						"url": "\/pages\/users\/user_address_list\/index"
					}
				]
				let order05 = {
					dfk: '/static/images/my-001.png',
					dfh: '/static/images/my-002.png',
					dsh: '/static/images/my-003.png',
					dpj: '/static/images/my-004.png',
					sh: '/static/images/my-005.png'
				};
				this.switchTab(order05);
			},

			initMessage() {
				getUnreadMessage().then(res => {
					if (res.status === 200) {
						this.messagecount = res.data.like + res.data.comment
					} else(err => {
						uni.showToast({
							title: '获取数据失败',
							icon: 'none'
						})
						console.log('获取数据失败', err);
					})
				}).catch(err => {
					console.log('获取数据失败', err);
				})
			},
			getUserInfo() {
				// 新接口无需传参
				getBaseUserInfo().then(res => {
					const cacheUserInfo = JSON.parse(Cache.get(USER_INFO));
					if (res.status === 200 && res.data) {
						// 将后端返回字段赋值给 userInfo
						this.userInfo = {
							...this.userInfo,
							...res.data,
							// 可选：显式转换数值字段（虽后端返回数字，但保险起见）
							phoneNumber: res.data.phone,
							follow_count: res.data.follow_count || 0,
							fans_count: res.data.fans_count || 0,
							comment_count: res.data.comment_count || 0,
							work_like_count: res.data.work_like_count || 0,
							share_count: res.data.share_count || 0,
							income: res.data.income || '0.00'
						};
						if (this.invite && this.invite.invite_uid) {
							//跳转设计师邀约界面
							console.error('1 秒后 跳转设计师邀约界面')
							console.error(this.invite)
							let _this = this
							setTimeout(function() {
								uni.navigateTo({
									url: '/pages/sub_base/designer-apply/index?invite_uid=' + _this
										.invite.invite_uid +
										'&invite_Name=' + _this.invite.invite_Name +
										'&phoneNumber=' + _this.userInfo.phoneNumber
								})
								console.error('已 跳转设计师邀约界面 清理缓存数据')
								//清理数据，避免重复跳转
								delete _this.invite
							}, 1000)
						}
					}
				}).catch(err => {
					console.log('获取用户信息失败', err);
					// 可选：失败时重置或提示
				});

				let that = this;
				getUserInfo().then((res) => {
					that.$store.commit('SETUID', res.data.uid);
					// 补充订单数量
					that.orderMenu.forEach((item, index) => {
						switch (item.title) {
							case '待付款':
								item.num = res.data.orderStatusNum.unpaid_count;
								break;
							case '待发货':
								item.num = res.data.orderStatusNum.unshipped_count;
								break;
							case '待收货':
								item.num = res.data.orderStatusNum.received_count;
								break;
							case '待评价':
								item.num = res.data.orderStatusNum.evaluated_count;
								break;
							case '售后/退款':
								item.num = res.data.orderStatusNum.refunding_count;
								break;
						}
					});
				}).catch(err => {
					uni.stopPullDownRefresh();
					console.error('获取用户基本信息失败', err);
				});
			},
			loadUserCreations() {
				getMyWorkList().then(res => {
					if (res.status === 200) {
						this.creations = (res.data.list || []).map(item => {
							let firstImage = this.imgHost + '/statics/images/no-thing.png'
							// let firstImage = '/static/base/empty.png';
							if (Array.isArray(item.images) && item.images.length > 0) {
								firstImage = item.images[0];
							}
							return {
								id: item.id,
								image: firstImage
							};
						});
					}
				}).catch(err => {
					console.error('加载我创作的作品失败', err);
					this.creations = [];
				});
			},
			loadCreativeWorks() {
				getWorkList('', 1, 15, 0, 1).then(res => {
					if (res.status === 200) {
						this.creativeWorks = (res.data.list || []).map(item => {
							let firstImage = '/static/base/empty.png';
							if (Array.isArray(item.images) && item.images.length > 0) {
								firstImage = item.images[0];
							}
							return {
								id: item.id,
								title: item.title || '无标题',
								author: item.nickname || '匿名用户',
								likes: item.likeNum || 0,
								image: firstImage,
								avatar: item.avatar || '/static/images/f.png'
							};
						});
					}
				}).catch(err => {
					console.error('加载共创中心作品失败', err);
					this.creativeWorks = [];
				});
			},
			//获取我想要的内容，去待评价数据
			loadMyPossessions() {
				const params = {
					type: 3,
					page: 1,
					limit: 20
				};
				getOrderList(params).then(res => {
					if (res.status === 200) {
						const list = res.data || [];
						const products = [];
						list.forEach(order => {
							if (Array.isArray(order.cartInfo)) {
								order.cartInfo.forEach(cartItem => {
									if (cartItem.productInfo && cartItem.productInfo.image) {
										products.push({
											id: cartItem.product_id,
											image: cartItem.productInfo.image
										});
									}
								});
							}
						});
						this.possessions = products;
					} else {
						this.possessions = [];
					}
				}).catch(err => {
					console.error('加载“我拥有的”失败', err);
					this.possessions = [];
				});
			},
			//获取我想要的数据
			loadMyWishes() {
				const params = {
					page: 1,
					limit: 20
				};
				getCollectUserList(params).then(res => {
					if (res.status === 200 && res.data && Array.isArray(res.data.list)) {
						this.wishes = res.data.list.map(item => {
							return {
								id: item.product_id,
								image: item.product.image
							};
						});
					} else {
						this.wishes = [];
					}
				}).catch(err => {
					console.error('加载“我想要的”失败', err);
					this.wishes = [];
				});
			},
			openLogin() {
				//#ifdef MP
				uni.navigateTo({
					url: '/pages/users/wechat_login/index'
				});
				//#endif
				//#ifdef H5
				uni.navigateTo({
					url: '/pages/users/login/index'
				});
				//#endif
			},
			goToSetting() {
				uni.navigateTo({
					url: '/pages/users/user_info/index'
				})
			},
			goToRecharge() {
				uni.navigateTo({
					// url: '/pages/sub_base/vip/index'
					url: '/pages/annex/vip_paid/index'
				})
			},
			goToMyCreations() {
				uni.navigateTo({
					url: '/pages/sub_base/my-created/index'
				})
			},
			//跳转到我拥有的
			goToMyPossessions() {
				// uni.navigateTo({
				// 	url: '/pages/goods/order_list/index'
				// })
				uni.navigateTo({
					url: '/pages/users/my_have/index'
				})
			},
			goToMyWishes() {
				uni.navigateTo({
					url: '/pages/users/user_goods_collection/index'
				})
			},
			goToCreativeList() {
				uni.navigateTo({
					url: '/pages/sub_base/creative-list/index'
				})
			},
			goToCreativeDetail(id) {
				uni.navigateTo({
					url: `/pages/sub_base/creative-detail/index?id=${id}`
				})
			},
			goToPossessionDetail(productId) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${productId}`
				});
			},
			goToWishDetail(productId) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${productId}`
				});
			},
			goToFollowList() {
				uni.navigateTo({
					url: `/pages/sub_base/follow-list/index?uid=${this.currentUId}`
				})
			},
			goToFansList() {
				uni.navigateTo({
					url: `/pages/sub_base/fans-list/index?uid=${this.currentUId}`
				})
			},
			goToDesignerApply() {
				//调整为分享小程序给用户，携带自定义参数
				// uni.navigateTo({
				// 	url: '/pages/sub_base/designer-apply/index'
				// })
				//h5环境下测试
				// #ifdef H5
				uni.navigateTo({
					url: '/pages/sub_base/designer-apply/index?invite_uid=' + 2 + '&invite_Name=' + 33
				})
				// #endif
			}
		}
	}
</script>


<style scoped>
	.order-status-num {
		min-width: 12rpx;
		background-color: #fff;
		color: rgb(254, 95, 45);
		border-radius: 15px;
		position: absolute;
		right: -14rpx;
		top: -15rpx;
		font-size: 20rpx;
		padding: 0 8rpx;
		border: 1px solid rgb(254, 95, 45);
	}

	.order-wrapper {
		background: #fff;
		margin: 20rpx 30rpx;
		position: relative;
		margin-top: 40rpx;
	}

	.order-hd {
		justify-content: space-between;
		padding: 30rpx 20rpx 10rpx 30rpx;
		margin-top: 25rpx;
		font-size: 30rpx;
		color: #282828;
	}

	.left {
		font-weight: bold;
	}

	.right {
		display: flex;
		align-items: center;
		color: #666666;
		font-size: 26rpx;
	}

	.icon-jiantou {
		margin-left: 5rpx;
		font-size: 26rpx;
	}

	.order-bd {
		display: flex;
		padding: 0 0;
	}

	.order-item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 20%;
		height: 140rpx;
	}

	.pic {
		position: relative;
		text-align: center;
	}

	.iconfont {
		font-size: 48rpx;
		color: var(--view-theme);
	}

	.pic image {
		width: 58rpx;
		height: 48rpx;
	}

	.txt {
		margin-top: 6rpx;
		font-size: 26rpx;
		color: #333;
	}

	.user-menus {
		background-color: #fff;
		margin: 0 30rpx;
	}

	.column-box {
		padding: 30rpx 20rpx 10rpx 30rpx;
	}

	.item {
		display: flex;
		align-items: center;
		margin-bottom: 40rpx;
		font-size: 26rpx;
	}

	.name {
		flex: 1;
		text-align: left;
	}

	.column-box image {
		width: 40rpx;
		height: 40rpx;
		margin-right: 20rpx;
	}

	.column-box .icon-jiantou {
		font-size: 26rpx;
		color: rgb(96, 98, 102);
	}

	.menu-title {
		padding: 30rpx 30rpx 40rpx;
		font-size: 30rpx;
		color: #282828;
		font-weight: bold;
	}

	.list-box {
		display: flex;
		flex-wrap: wrap;
	}

	.list-box .item {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-direction: column;
		width: 25%;
		margin-bottom: 40rpx;
		font-size: 26rpx;
		color: #333333;
	}

	.list-box .name {
		flex: 1;
		text-align: left;
	}

	.list-box image {
		width: 52rpx;
		height: 52rpx;
		margin-bottom: 18rpx;
	}

	button {
		font-size: 28rpx;
	}

	.designer-icon {
		width: 22rpx;
		height: 22rpx;
		margin-right: 4rpx;
		/* 调整图标和文字之间的间距 */
		/* 如果需要垂直居中，可以加 margin-bottom: -2rpx; */
	}

	.designer-tag {
		display: flex;
		align-items: center;
		/* 保持原有样式 */
		font-size: 24rpx;
		padding: 0 14rpx 8rpx;
		/* 可根据需要调整 */
		margin-left: 24rpx;
		margin-top: 4rpx;
		border-radius: 30rpx;
		border: 2rpx solid #000;
		height: 44rpx;

		/* 新增：设置背景色和文字颜色，使其更清晰 */
		background-color: #fff;
		/* 或者透明 background-color: transparent; */
		color: #000;
	}

	.container {
		min-height: 100vh;
		/* background-color: #ffffff; */
	}

	.title {
		font-size: 42rpx;
		margin-bottom: 14rpx;
		text-align: center;
	}

	.content {
		height: calc(100vh - 0rpx);
	}

	.empty-placeholder {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 200rpx;
		/* 根据需要调整高度 */
	}

	.empty-image {
		width: 180rpx;
		height: 180rpx;
		opacity: 0.6;
	}

	.user-section {
		background-color: #ffffff;
		margin: 9rpx 17rpx;
		border-radius: 21rpx;
		padding: 28rpx;
	}

	.user-info {
		display: flex;
		align-items: center;
	}

	.identity-title {
		background-color: #E6F2F9;
		color: #84BDE3;
		padding: 2rpx 12rpx;
		border-radius: 12rpx;
		margin-left: 28rpx;
	}

	.phone-number-text {
		font-size: 22rpx;
	}

	.signature-text {
		font-size: 22rpx;
	}

	.avatar-container {
		position: relative;
	}

	.avatar-vip-icon {
		position: absolute;
		bottom: 0;
		right: 0;
		width: 44rpx;
		height: 44rpx;
		border-radius: 50%;
		background-color: #fff;
		box-sizing: border-box;
	}

	.user-avatar {
		width: 104rpx;
		height: 104rpx;
		border-radius: 52rpx;
	}

	.user-details {
		flex: 1;
		margin-left: 28rpx;
		position: relative;
		/* 		display: flex;
		align-items: center; */
	}

	.user-name {
		font-size: 42rpx;
		font-weight: 500;
		color: #333333;
	}

	.mvp-img {
		height: 38rpx;
		/* width: 38rpx; */
		width: 138rpx;
		margin-left: 20rpx;
	}

	.vip-expire {
		font-size: 21rpx;
		color: #666666;
		margin-left: 3rpx;
	}

	.setting-icon,
	.setting-img {
		width: 42rpx;
		height: 42rpx;
	}

	.vip-income-box {
		margin-top: 30rpx;
		margin-bottom: 50rpx;
		padding: 0 30rpx;
	}

	.membership-section {
		position: relative;
		/* margin: 0 61rpx; */
		border-radius: 21rpx 21rpx 0 0;
		padding: 28rpx;
		display: flex;
		align-items: center;
		z-index: 0;
		/* background-color: #e0b756 */
		background-size: 100%;
	}

	.vip-bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: -1;
	}

	.income-bg {
		position: absolute;
		top: -20rpx;
		left: -22rpx;
		width: 106%;
		height: 120%;
		/* z-index: -1; */
	}

	.vip-text {
		margin-left: 140rpx;
		display: grid;
	}

	.membership-bg {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: -1;
		width: 100%;
		height: 100%;
		border-radius: 21rpx 21rpx 0 0;
		/* background-color: #edc565; */
	}

	.vip-icon {
		width: 52rpx;
		height: 52rpx;
		margin-right: 21rpx;
		margin-left: 24rpx;
	}

	.membership-title {
		font-size: 24rpx;
		color: #f2ddcb;
		margin-right: 14rpx;
	}

	.membership-expire {
		font-size: 21rpx;
		color: #c7b6a8;
		margin-right: 28rpx;
	}

	.renew-btn {
		margin-left: auto;
		padding: 2rpx 36rpx;
		background-color: #edc69d;
		border-radius: 35rpx;
	}

	.renew-text {
		font-size: 26rpx;
		color: #0000000;
	}

	.stats-section {
		margin: 17rpx 17rpx;
		padding: 28rpx;
	}

	.stats-header {
		position: relative;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 24rpx 40rpx 36rpx;
		/* margin: -18rpx 42rpx 36rpx; */
		/* border: 2rpx solid #c7c7c7; */
	}

	.stats-view {
		z-index: 999;
		margin-right: 10rpx;
		/* font-size: 35rpx; */
		/* color: #666666; */
		/* border-bottom: 2rpx solid #000; */
	}

	.stats-content {
		display: grid;
		grid-template-columns: repeat(5, 1fr);
		gap: 14rpx;
	}

	.stat-item-first,
	.stat-item {

		display: flex;
		flex-direction: column;
		align-items: center;
		text-align: center;
		position: relative;
	}

	.stat-item:not(:last-child)::after {
		content: '';
		position: absolute;
		top: 22rpx;
		right: -17rpx;
		width: 1rpx;
		transform: scaleX(0.3);
		/* 水平压缩到一半宽度 */
		height: 60%;
		background-color: #000000;
	}

	.stat-number-first {
		font-size: 47rpx;
		font-weight: 600;
		color: #000;
	}

	.stat-number {
		font-size: 32rpx;
		font-weight: 600;
		/* color: #000; */
	}
	.stat-item-img{
		width: 45rpx;
		height: 45rpx;
		margin-bottom: 15rpx;
	}
	.stat-label {
		font-size: 24rpx;
		color: #666666;
	}

	.section {
		padding: 17rpx 0;
		border-radius: 14rpx;
		background-color: #F2F8FC;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 28rpx;
		margin-bottom: 21rpx;
		margin-top: 52rpx;
	}

	.section-title {
		font-size: 28rpx;
		font-weight: 600;
		color: #333333;
	}

	.second-more-icon {
		width: 36rpx;
		height: 36rpx;
	}

	.more-btn {
		font-size: 24rpx;
		color: #000000;
		border-bottom: 2rpx solid #000000;
	}

	.horizontal-scroll {
		white-space: nowrap;
		padding: 0 28rpx;
		overflow-x: auto;
	}

	.my-creations-grid-container {
		display: grid;
		grid-template-rows: auto auto;
		grid-auto-columns: 191rpx;
		grid-auto-flow: column;
		gap: 16rpx;
		overflow-x: auto;
		white-space: nowrap;
		min-width: max-content;
	}

	.creation-item {
		width: 191rpx;
		/* background-color: #ffffff;
		box-shadow: 0 3rpx 14rpx rgba(0, 0, 0, 0.1); */
		overflow: hidden;
		position: relative;
		flex-shrink: 0;
	}

	.creation-item.first-item {
		grid-row: span 2;
	}

	.image-container {
		position: relative;
		height: 100%;
		padding-top: 100%;
		overflow: hidden;
	}

	.product-image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
	}

	.product-list {
		display: flex;
		min-width: max-content;
	}

	.product-item {
		width: 174rpx;
		margin-right: 16rpx;
		/* background-color: #ffffff;
		box-shadow: 0 3rpx 14rpx rgba(0, 0, 0, 0.1); */
		overflow: hidden;
		position: relative;
		flex-shrink: 0;
	}

	.creative-list {
		display: flex;
	}

	.creative-item {
		width: 280rpx;
		overflow: hidden;
		position: relative;
		flex-shrink: 0;
		margin-right: 9rpx;
	}

	.creative-item.last-item {
		width: 140rpx;
		margin-right: 0;
	}

	.creative-container {
		position: relative;
		width: 100%;
		padding-top: 133.33%;
		overflow: hidden;
	}

	.creative-image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
	}

	.creative-info {
		padding: 14rpx;
		z-index: 1;
		border-radius: 7rpx;
	}

	.creative-title {
		font-size: 21rpx;
		color: #000000;
		display: block;
		margin-bottom: 10rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.creative-meta {
		display: flex;
		align-items: center;
		gap: 14rpx;
	}

	.avatar {
		width: 24rpx;
		height: 24rpx;
		border-radius: 50%;
		background-color: #ccc;
	}

	.creative-author,
	.creative-likes {
		font-size: 17rpx;
		color: #000000;
	}

	.creative-likes {
		color: #ff3366;
	}

	.view-more-btn {
		width: 23%;
		height: 65rpx;
		padding-left: 12rpx;
		border-radius: 100rpx;
		line-height: 64.1rpx;
		text-align: center;
		border: 1rpx solid #787878;
		/* background: #fff; */
		color: #333333;
		margin: 50.3rpx auto;
		font-size: 27.7rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.more-icon {
		width: 33rpx;
		height: 33rpx;
		margin-left: 2rpx;
	}
</style>